﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sharp.Domain.CMSBoundedContext.AritcleModule.Aggregates
{
    public partial class GatherHistoryRepository
    {
        /// <summary>
        /// 记录Url
        /// </summary>
        /// <param name="url"></param>
        public void LogUrl(string url)
        {

            string md5 = url.Md5();
            bool exists = this.Exists(x => x.Md5 == md5);
            if (exists == false)
            {
                GatherHistory info = new GatherHistory
                {
                    Url = url,
                    Md5 = md5
                };

                this.Add(info);
                this.Context.Commit();
            }

        }

        /// <summary>
        /// URL 是否存在
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public bool Exists(string url)
        {
            string md5 = url.Md5();
            return this.Exists(x => x.Md5 == md5);
        }
    }
}